import React from "react";
import ReactDom from "react-dom"

class Clock extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            time: new Date().toLocaleTimeString()
        }
    }

    render() {
        return (
            <div>
                <p>now time is {this.state.time}</p>
            </div>
        )
    }
    componentDidMount() {
        setInterval(() => {
            this.setState({
                time: new Date().toLocaleTimeString()
            })
        }, 1000)
    }
}
ReactDom.render(
    <Clock/>,
    document.querySelector('#root')
)